<?php
// +----------------------------------------------------------------------
// | 萤火商城系统 [ 致力于通过产品和服务，帮助商家高效化开拓市场 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2024 https://www.yiovo.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed 这不是一个自由软件，不允许对程序代码以任何形式任何目的的再发行
// +----------------------------------------------------------------------
// | Author: 萤火科技 <admin@yiovo.com>
// +----------------------------------------------------------------------
declare (strict_types = 1);

namespace app\api\model\learn;
use app\common\model\learn\Clock as ClockModel;

/**
 *
 * Class Article
 * @package app\api\model
 */
class Clock extends ClockModel {

	public function add($userId, $time) {
		$log = $this->where('user_id', $userId)->where('date', date('Y-m-d'))->find();
		if (!$log) {
			$data['user_id'] = $userId;
			$data['time'] = $time;
			$data['date'] = Date('Y-m-d');
			$data['store_id'] = self::$storeId;
			$this->save($data);
		} else {
			$this->where('user_id', $userId)->where('date', date('Y-m-d'))->inc('time', $time)->update();
		}

		return true;
	}

}